package mysql

import "gorm.io/gorm"

type Good struct {
	gorm.Model
	UserId    int     `gorm:"type:int(10);index;not null;comment:用户ID"`
	GoodTitle string  `gorm:"type:varchar(10);not null;comment:商品标题"`
	GoodCover string  `gorm:"type:varchar(200);not null;comment:商品封面"`
	GoodPrice float64 `gorm:"type:decimal(10,2);not null;comment:商品单价"`
	GoodStock int     `gorm:"type:int(10);not null;comment:商品库存"`
	GoodState int     `gorm:"type:int(10);not null;comment:商品状态"`
	GoodTypes int     `gorm:"type:int(10);not null;comment:商品类型"`
}

func (g *Good) Create() error {
	return DB.Debug().Create(&g).Error
}
func (g *Good) Detail(goodId int) error {
	return DB.Debug().Where("id=?", goodId).Limit(1).Find(&g).Error
}
